﻿using System;
using LoD.Contracts;
using LoD.Server.Core.Interfaces;


namespace LoD.Server.Core {
    public abstract class Entity : IEntity, IComparable<Entity> {
        protected Entity() { this.Serial = Guid.NewGuid(); }

        #region IComparable<Entity> Members

        public int CompareTo(Entity other) { return this.CompareTo((IEntity)other); }

        #endregion

        #region IEntity Members

        public int CompareTo(IEntity other) {
            if (other == null) return -1;

            return this.Serial.CompareTo(other.Serial);
        }

        public int CompareTo(object other) {
            if (other == null || other is IEntity) return this.CompareTo((IEntity)other);

            throw new ArgumentException();
        }

        public Guid Serial { get; private set; }

        public WorldPoint3D Location { get; private set; }

        public int X {
            get { return this.Location.X; }
        }

        public int Y {
            get { return this.Location.Y; }
        }

        public int Z {
            get { return this.Location.Z; }
        }

        public Map Map { get; private set; }

        public void Delete() { }

        public void ProcessDelta() { }

        #endregion
    }
}